<%@taglib uri="/WEB-INF/webflow.tld" prefix="webflow" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@page import="com.broadvision.ssp.webflow.WebflowHelper" %>
<%@page import="com.broadvision.ssp.common.SSContext" %>
<%@page import="com.broadvision.ssp.common.TaskPriority" %>
<%@page import="com.broadvision.ssp.client.workflow.*" %>
<%@page import="com.broadvision.ssp.client.*" %>
<%@page import="com.broadvision.ssp.util.*" %>
<%@page import="com.broadvision.portal.services.microsite.BizProcessMicrosite" %>
<%@page import="com.broadvision.portal.services.microsite.Group" %>
<%@page import="com.broadvision.portal.services.PortalVisitor" %>
<%@page import="com.broadvision.visitor.client.VisitorManager" %>
<%@page import="java.util.Locale" %>

<webflow:advance id="url"/>
<%
 SSContext ctx = WebflowHelper.getWebflowContext(request);
 Long micrositeId = (Long) ctx.getAttribute("micrositeId");

 String micrositeIdStr = null;

 if (micrositeId == null)
  System.out.println("Microsite Id is null.");

 micrositeIdStr = micrositeId.toString();
 pageContext.setAttribute("micrositeIdStr",micrositeIdStr);
 TaskItem taskItem = (TaskItem) ctx.getAttribute(SSContext.TASK_ITEM_CTX_OBJ);
  String priority=TaskPriority.getTaskPriorityString(taskItem.getPriority().toString());
 pageContext.setAttribute("taskItemBean", taskItem);

 Integer serviceId = (Integer) ctx.getAttribute(SSContext.SERVICE_ID_CTX_NAME);
 String workflowInstanceId = (String) ctx.getAttribute(SSContext.WORKFLOW_INSTANCE_ID_CTX_NAME);
 SspInstance sspInstance = SspInstance.getSspInstance(Long.parseLong(workflowInstanceId));

 String sspName = sspInstance.getSspName();
 Long userId = (Long) ctx.getAttribute(SSContext.USER_ID_CTX_NAME);

 // use pmcadmin as the owner to  retrieve view only ms
 VisitorManager visitorMgr = new VisitorManager();
 PortalVisitor pmcAdmin = new PortalVisitor(visitorMgr.getVisitor(TableConstants.BVADMIN));
 
 PortalVisitor portalVisitor = new PortalVisitor (userId.longValue());
 BizProcessMicrosite microsite = new BizProcessMicrosite(serviceId.intValue(), micrositeId.longValue(), pmcAdmin);

 Group participantGroup = microsite.getParticipantGroup();
 if (!participantGroup.isMember(portalVisitor, false))
   participantGroup.addVisitor(portalVisitor);

 Group ownerGrp = microsite.getOwnerGroup();
 if (!ownerGrp.isMember(portalVisitor, false))
   ownerGrp.addVisitor(portalVisitor);

%>

	  <!-- Zone 5 starts here.  -->
		  
		  <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
		    <tr>
			<td valign="top" width="100%">
		    
			<div class="app_pageTitle"><bean:write name="taskItemBean" property="name" /></div> 
			
			<div class="app_pageSubtitle">
			    <span class="left"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.TaskInformation" /></span>
				<span class="right">
				  &nbsp;
			    </span>
			</div> 
			<!--end page title area here-->
			
			
			 <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Account information">
			   <tr> 
			     <td class="label" width="20%"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.duedate" />:</td>
			     <td class="labelField" width="80%">
            <bean:write name="taskItemBean" property="duedate" formatKey="format.datetime.medium" />
            </td>
			   </tr>
			   <tr> 
			     <td class="label" width="20%"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.priority" /> :</td>
			     <td class="labelField" width="80%">
                                <%=priority%>
				 </td>
			   </tr>
			   <tr> 
			     <td class="label" width="20%"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.processName" />:</td>
			     <td class="labelField" width="80%">
           <%=sspName%>
				 </td>
			   </tr>
			   <tr> 
			     <td class="label" width="20%"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.instructions" />:</td>
			     <td class="labelField" width="80%">
                             <p><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.note1" arg0="<%=microsite.getName()%>" />
             <% Locale locale = (Locale)session.getAttribute(org.apache.struts.Globals.LOCALE_KEY); 
		if (locale.getLanguage().equals(new Locale("ja", "", "").getLanguage())){ %>
	                     <p><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.note2" />
	                     <html:link page="/cs/setupCollaboration.do?currentAction=setup" paramId="micrositeId" paramName="micrositeIdStr" styleClass="blueTextLink"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.clickHere" /></html:link> 
             <%   }else{ %>
	                    <p><html:link page="/cs/setupCollaboration.do?currentAction=setup" paramId="micrositeId" paramName="micrositeIdStr" styleClass="blueTextLink"><bean:message bundle="appCommonRes"   key="cs.collaboration.setup.clickHere" /></html:link> 
                 <bean:message bundle="appCommonRes"   key="cs.collaboration.setup.note2" />

			<% } %>
				 </td>
			   </tr>
			 </table>
	     </td>
		  </tr>
		</table>
		<!--end zone 5 content here -->		
